package com.irononetech.android.MultilevelListView;

import java.util.Arrays;

import android.app.AlertDialog;
import android.app.ExpandableListActivity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.irononetech.android.formcomponent.FormObject;
import com.irononetech.android.formcomponent.view.VehicleDetailsActivity;
import com.irononetech.android.Application.Application;
import com.irononetech.android.claimsone.R;

public class ExpList3_Van extends ExpandableListActivity {
	Logger LOG = LoggerFactory.getLogger(ExpList3_Van.class);

	private ColorExpListAdapterVan colorExpListAdapter;
	FormObject fo;
	static boolean booleanlistVan[][][][];
	static boolean booleanprelistVan[][][][];
	
	boolean booleanlistVanCopy[][][][];
	boolean booleanprelistVanCopy[][][][];
	int p1, p2, p3, p4;
	Button resetBtn;
	LinearLayout damageditems_header;
	
	EditText otherfield;

	static final String listdesc[][][][] = { { // grey
			{ // lightgray
			{ "Van", "Front face panel" }, { "Front buffer", "" },
					{ "Front grill", "" }, { "Dash board", "" },
					{ "Front badge", "" }, { "A/C blower", "" },
					{ "A/C cooler", "" }, { "Horn", "" },
					{ "Front windscreen", "" },
					{ "Front single windscreen beading", "" },
					{ "L/H/S front buffer end", "" },
					{ "R/H/S front buffer end", "" },
					{ "R/H/S head lamp", "" }, { "L/H/S head lamp", "" },
					{ "R/H/S head lamp frame", "" },
					{ "L/H/S head lamp frame", "" },
					{ "R/H/S front signal lamp", "" },
					{ "L/H/S front signal lamp", "" },
					{ "R/H/S front parking lamp", "" },
					{ "L/H/S front parking lamp", "" },
					{ "A/C Condensers", "" }, { "A/C Filter", "" },
					{ "Air horn", "" }, { "Front number plate", "" },
					{ "Front number plate lamp", "" }, { "Fog lamps", "" },
					{ "Face panel", "" }, { "R/H/S side mirror", "" },
					{ "R/H/S Side mirror arm", "" },
					{ "L/H/S side mirror", "" },
					{ "L/H/S Side mirror arm", "" },
					{ "L/H/S side ball mirror", "" },
					{ "R/H/S wiper blade", "" }, { "R/H/S wiper arm", "" },
					{ "L/H/S wiper blade", "" }, { "L/H/S wiper arm", "" },
					{ "Center upper shell", "" }, { "Center lower shell", "" },
					{ "Trim package", "" },
					{ "Face cut/nose cut/half cut", "" } },
			{ // darkgray
			{ "Van", "Right body panel" }, { "R/H/S driver door", "" },
					{ "R/H/S cut glass", "" }, { "R/H/S fit glass", "" },
					{ "R/H/S rain gutter", "" }, { "R/H/S body molding", "" },
					{ "R/H/S door hinges", "" }, { "R/H/S front tire", "" },
					{ "R/H/S driver door", "" },
					{ "R/H/S Driver door glass", "" },
					{ "R/H/S Driver door glass beading", "" },
					{ "R/H/S Door hinges", "" }, { "R/H/S Cut glass", "" },
					{ "R/H/S Cut glass frames", "" },
					{ "R/H/S Fit glass", "" },
					{ "R/H/S Fit glass frames", "" },
					{ "R/H/S Cut glass beading", "" },
					{ "R/H/S Fit glass beading", "" },
					{ "R/H/S Rain gutter", "" },
					{ "R/H/S Body aluminum molding", "" },
					{ "R/H/S Body molding", "" }, { "R/H/S Front tire", "" },
					{ "R/H/S Front rim", "" }, { "R/H/S Rear tire outer", "" },
					{ "R/H/S Rear tire outer rim", "" },
					{ "R/H/S Rear tire inner", "" },
					{ "R/H/S Rear tire inner rim", "" },
					{ "R/H/S Mirror", "" },
					{ "R/H/S Front tire Wheel nuts", "" },
					{ "R/H/S Rear tire outer Wheel nuts", "" },
					{ "R/H/S Rear tire inner Wheel nuts", "" },
					{ "Rim cups (if available)", "" },
					{ "R/H/S center door", "" },
					{ "R/H/S center door glass", "" },
					{ "R/H/S center door glass beading", "" },
					{ "R/H/S center hinges", "" },
					{ "R/H/S Mudguard guard arch", "" },
					{ "R/H/S Mudguard arch cover", "" },
					{ "M R/H/S mudguard beading", "" } },
			{ // darkgray
			{ "Van", "Left body panel" }, { "L/H/S front door", "" },
					{ "L/H/S front board", "" }, { "L/H/S cut glasses", "" },
					{ "L/H/S foot board", "" }, { "L/H/S fit glasses", "" },
					{ "L/H/S body rubber", "" },
					{ "L/H/S rear tire inner", "" },
					{ "L/H/S Front door glass", "" },
					{ "L/H/S Front door glass beading", "" },
					{ "L/H/S Front door rubber flap", "" },
					{ "L/H/S Front door winder", "" },
					{ "L/H/S Foot board lamp", "" },
					{ "L/H/S Front rain gutter", "" },
					{ "L/H/S Body aluminum molding", "" },
					{ "L/H/S Body rubber molding", "" },
					{ "L/H/S Cut glasses frames", "" },
					{ "L/H/S Fit glasses frames", "" },
					{ "L/H/S Cut glass beading", "" },
					{ "L/H/S Fit glasses beading", "" },
					{ "L/H/S center foot board", "" },
					{ "L/H/S center foot board lamp", "" },
					{ "L/H/S center foot board door", "" },
					{ "L/H/S center foot board door glass", "" },
					{ "L/H/S center foot board door beading", "" },
					{ "L/H/S center foot board door rubber flap", "" },
					{ "L/H/S center door", "" },
					{ "L/H/S center door glass", "" },
					{ "L/H/S center door glass beading", "" },
					{ "L/H/S center hinges", "" },
					{ "L/H/S Rear rain gutter", "" },
					{ "L/H/S Front tire", "" }, { "L/H/S Front tire rim", "" },
					{ "L/H/S Rear tire outer", "" },
					{ "L/H/S Rear tire outer rim", "" },
					{ "L/H/S Rear tire inner rim", "" },
					{ "L/H/S Front tire Wheel nuts", "" },
					{ "L/H/S Rear tire outer Wheel nuts", "" },
					{ "L/H/S Rear tire inner Wheel nuts", "" },
					{ "L/H/S Rim cups (if available)", "" } },
			{ // darkgray
			{ "Van", "Rear side" }, { "Rear buffer", "" },
					{ "Rear windscreen", "" }, { "R/H/S Rear windscreen", "" },
					{ "L/H/S Rear windscreen", "" },
					{ "R/H/S Rear windscreen beading", "" },
					{ "R/H/S Rear windscreen beading", "" },
					{ "Rear windscreen beading", "" },
					{ "Rear name board box glass", "" },
					{ "Rear name board box glass beading", "" },
					{ "Rear name board box glass lamp", "" },
					{ "L/H/S tail light rear", "" },
					{ "R/H/S Rear tail light", "" },
					{ "L/H/S Rear tail light", "" },
					{ "R/H/S rear parking lamp", "" },
					{ "L/H/S rear parking lamp", "" },
					{ "R/H/S rear buffer end", "" },
					{ "L/H/S rear buffer end", "" }, { "Dickey door", "" },
					{ "Dickey door lights", "" },
					{ "Dickey door garnish", "" }, { "Dickey door locks", "" },
					{ "Dickey door handles", "" },
					{ "Dickey door ladder", "" },
					{ "Dickey door beadings", "" }, { "Rear umber plate", "" },
					{ "Rear umber plate lamp", "" },
					{ "Back body aluminum molding", "" },
					{ "Back body rubber beading", "" },
					{ "Rear windscreen mirror", "" }, { "Wiper arm", "" },
					{ "Wiper blade", "" } },
			{ { "Van", "Engine compartment and components" },
					{ "Diesel, petrol engine (gasoline engine)", "" },
					{ "Accessory belt", "" }, { "Air duct", "" },
					{ "Air intake housing", "" },
					{ "Air intake manifold", "" }, { "Camshaft", "" },
					{ "Camshaft bearing", "" }, { "Camshaft fastener", "" },
					{ "Camshaft follower", "" },
					{ "Camshaft locking plate", "" },
					{ "Camshaft pushrod", "" }, { "Camshaft spacer ring", "" },
					{ "Connecting rod", "" }, { "Connecting rod bearing", "" },
					{ "Connecting rod bolt", "" },
					{ "Connecting rod washer", "" }, { "Crank case", "" },
					{ "Crank pulley", "" }, { "Crankshaft", "" },
					{ "Crankshaft oil seal", "" }, { "Cylinder head", "" },
					{ "Cylinder head cover", "" },
					{ "Other cylinder head cover parts", "" },
					{ "Cylinder head gasket", "" }, { "Distributor", "" },
					{ "Distributor cap", "" }, { "Drive belt", "" },
					{ "Engine block", "" }, { "Engine block parts", "" },
					{ "Engine cradle", "" },
					{ "Engine shake damper and vibration absorber", "" },
					{ "Engine valve", "" }, { "Fan belt", "" },
					{ "Gudgeon pin (wrist pin)", "" },
					{ "Harmonic balancer", "" }, { "Heater", "" },
					{ "Mounting bolt", "" },
					{ "Piston pin and crank pin", "" },
					{ "Piston pin bush", "" },
					{ "Piston ring and circlip", "" }, { "Piston valve", "" },
					{ "Poppet valve", "" },
					{ "PCV valve (positive crankcase ventilation valve)", "" },
					{ "Pulley part", "" }, { "Rocker arm", "" },
					{ "Rocker cover Starter motor", "" },
					{ "Rocker cover Starter pinion", "" },
					{ "Rocker cover Starter ring", "" },
					{ "Turbocharger and supercharger", "" }, { "Tappet", "" },
					{ "Timing tape ", "" }, { "Valve cover", "" },
					{ "Valve housing", "" }, { "Valve spring", "" },
					{ "Valve stem seal", "" }, { "Water pump pulley", "" } },
			{ { "Van", "Engine cooling system" }, { "Air blower", "" },
					{ "Coolant hose cooling fan", "" }, { "Fan blade", "" },
					{ "Fan clutch", "" }, { "Radiator bolt", "" },
					{ "Radiator shroud", "" }, { "Radiator gasket", "" },
					{ "Radiator pressure cap", "" }, { "Water neck", "" },
					{ "Water neck o-ring", "" }, { "Water pipe", "" },
					{ "Water pump", "" }, { "Water pump gasket", "" },
					{ "Water tank", "" }, { "Thermostat", "" } },
			{ { "Van", "Engine oil system" }, { "Oil filter", "" },
					{ "Oil gasket", "" }, { "Oil pan", "" },
					{ "Oil pipe", "" }, { "Oil pump", "" },
					{ "Oil strainer", "" } },
			{ { "Van", "Exhaust system" }, { "Catalytic converter", "" },
					{ "Exhaust clamp and bracket", "" },
					{ "Exhaust flange gasket", "" }, { "Exhaust gasket", "" },
					{ "Exhaust manifold", "" },
					{ "Exhaust manifold gasket", "" }, { "Exhaust pipe", "" },
					{ "Heat shield", "" }, { "Heat sleeving and tape", "" },
					{ "Muffler (silencer)", "" } },
			{ { "Van", "Fuel supply system" }, { "Air filter", "" },
					{ "Carburetor", "" }, { "Carburetor parts", "" },
					{ "Choke cable", "" }, { "EGR valve", "" },
					{ "Fuel cap", "" }, { "Fuel cell", "" },
					{ "Fuel cell component", "" }, { "Fuel cooler", "" },
					{ "Fuel distributor", "" }, { "Fuel filter", "" },
					{ "Fuel filter seal", "" }, { "Fuel injector", "" },
					{ "Fuel injector nozzle", "" }, { "Fuel pump", "" },
					{ "Fuel pump gasket", "" },
					{ "Fuel pressure regulator", "" }, { "Fuel rail", "" },
					{ "Fuel tank", "" }, { "Fuel tank cover", "" },
					{ "Fuel water separator", "" }, { "Intake manifold", "" },
					{ "Intake manifold gasket", "" },
					{ "LPG (Liquefied petroleum gas) system assembly", "" },
					{ "Throttle body", "" }, { "Universal joint", "" } },
			{ { "Van", "Other miscellaneous parts" },
					{ "Adhesive tape and foil", "" }, { "Bolt cap", "" },
					{ "License plate bracket", "" },
					{ "Speedometer cable", "" }, { "Cotter pin", "" },
					{ "Decal", "" }, { "Dashboard", "" },
					{ "Center console", "" }, { "Glove compartment", "" },
					{ "Drag link", "" }, { "Dynamic seal", "" },
					{ "Fastener", "" },
					{ "Gasket: Flat, molded, profiled", "" },
					{ "Hood and trunk release cable", "" },
					{ "Horn and trumpet horn", "" },
					{ "Injection-molded parts", "" },
					{ "Instrument cluster", "" }, { "Label", "" },
					{ "Mirror", "" }, { "Mount and mounting", "" },
					{ "Name plate", "" }, { "Flange nut", "" },
					{ "Hex nut", "" }, { "O-ring", "" }, { "Paint", "" },
					{ "Rivet", "" }, { "Rubber (extruded and molded)", "" },
					{ "Screw", "" }, { "Shim", "" }, { "Sun visor", "" } }, } };

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		try {
			super.onCreate(icicle);
			LOG.debug("ENTRY onCreate");
			setContentView(R.layout.multilevel_expandable_list_main);
			fo = com.irononetech.android.Application.Application.getFormObjectInstance();
			otherfield = (EditText) findViewById(R.id.damagedItemsOtherField);

			resetBtn = (Button) findViewById(R.id.resetButton);
			damageditems_header = (LinearLayout) findViewById(R.id.damageditems_header);
			
			p1 = Application.get4DArrSizeSec1();
			p2 = Application.get4DArrSizeSec2();
			p3 = Application.get4DArrSizeSec3();
			p4 = Application.get4DArrSizeSec4();
			
			if (fo.getisPreSelected()) // PRE
			{
				otherfield.setText(fo.getpredamagedItemsOtherField());
				booleanprelistVan = Arrays.copyOf(fo.getBooleanprelistVan(), fo.getBooleanprelistVan().length);
				
				booleanprelistVanCopy = new boolean[p1][p2][p3][p4];
				for (int i = 0; i < p1; i++) {
					for (int j = 0; j < p2; j++) {
						for (int k = 0; k < p3; k++) {
							booleanprelistVanCopy[i][j][k][0] = booleanprelistVan[i][j][k][0];
							booleanprelistVanCopy[i][j][k][1] = booleanprelistVan[i][j][k][1];
						}
					}
				}
				colorExpListAdapter = new ColorExpListAdapterVan(this, getExpandableListView(), listdesc);
				setListAdapter(colorExpListAdapter);
				damageditems_header.setBackgroundDrawable(getResources().getDrawable(R.drawable.predamageditems_header));
			} else {
				otherfield.setText(fo.getdamagedItemsOtherField());
				booleanlistVan = Arrays.copyOf(fo.getBooleanlistVan(), fo.getBooleanlistVan().length);
				
				booleanlistVanCopy = new boolean[p1][p2][p3][p4];
				for (int i = 0; i < p1; i++) {
					for (int j = 0; j < p2; j++) {
						for (int k = 0; k < p3; k++) {
							booleanlistVanCopy[i][j][k][0] = booleanlistVan[i][j][k][0];
							booleanlistVanCopy[i][j][k][1] = booleanlistVan[i][j][k][1];
						}
					}
				}
				colorExpListAdapter = new ColorExpListAdapterVan(this, getExpandableListView(), listdesc);
				setListAdapter(colorExpListAdapter);
				damageditems_header.setBackgroundDrawable(getResources().getDrawable(R.drawable.damageditems_header));
			}
			
			if (!fo.isEditable()) {
				editDisable();
			}
			
			LOG.debug("SUCCESS onCreate");
		} catch (Exception e) {
			LOG.error("onCreate:10328");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}

	public void editDisable() {
		try {
			otherfield.setFocusable(false);
			resetBtn.setVisibility(View.GONE);
			
			/*if (fo.getisPreSelected()) // PRE
			{
				back.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.back_button_xml));
			} else {
				back.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.back_button_xml));
			}*/
		} catch (Exception e) {
			LOG.error("editEnable:10330");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}

	/*public void editEnable() {
		try {
			otherfield.setFocusable(true);

			if (fo.getisPreSelected()) // PRE
			{
				back.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.back_button_xml));
			} else {
				back.setBackgroundDrawable(getResources().getDrawable(
						R.drawable.cancel_button_xml));
			}
		} catch (NotFoundException e) {
			LOG.error("editEnable:10331");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		} catch (Exception e) {
			LOG.error("editEnable:10332");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}*/

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return false;
		}
		return super.onKeyDown(keyCode, event);
	}

	public void multilevel_ok_click(View v) {
		okCommon();
	}

	private void okCommon() {
		try {
			if (fo.getisPreSelected()) // PRE
			{
				fo.setBooleanprelistVan(booleanprelistVan);
				fo.setpredamagedItemsOtherField(otherfield.getText().toString().trim());
			} else {
				fo.setBooleanlistVan(booleanlistVan);
				fo.setdamagedItemsOtherField(otherfield.getText().toString().trim());
			}
			Application.setFormObjectInstance(fo);
			
			Intent mIntent = new Intent(ExpList3_Van.this, VehicleDetailsActivity.class);
			mIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
			startActivity(mIntent);
			finish();
		} catch (Exception e) {
			LOG.error("okCommon:10301");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}
	
	private void backCommon() {
		try {
			if (fo.getisPreSelected()) // PRE
			{
				fo.setpredamagedItemsOtherField(fo.getpredamagedItemsOtherField());
				fo.setBooleanprelistVan(booleanprelistVanCopy);
			} else {
				fo.setdamagedItemsOtherField(fo.getdamagedItemsOtherField());
				fo.setBooleanlistVan(booleanlistVanCopy);
			}
			Application.setFormObjectInstance(fo);
		} catch (Exception e) {
			LOG.error("backCommon:13388");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}
	
	public void multilevel_back_button(View v) {
		try {
			if (fo.isEditable()) {
				
				boolean isSameList = true;
				boolean isSameText = false;
				
				if (fo.getisPreSelected()) // PRE
				{
					//isSameList = Arrays.equals(booleanprelistBus, booleanprelistBusCopy);
					for (int i = 0; i < p1; i++) {
						for (int j = 0; j < p2; j++) {
							for (int k = 0; k < p3; k++) {
								if (booleanprelistVanCopy[i][j][k][0] != booleanprelistVan[i][j][k][0]) {
									isSameList = false;
									break;
								}
								if (booleanprelistVanCopy[i][j][k][1] != booleanprelistVan[i][j][k][1]) {
									isSameList = false;
									break;
								}
							}
						}
					}
					
					if (otherfield.getText().toString().toLowerCase().equals((fo.getpredamagedItemsOtherField().toLowerCase())))
						isSameText = true;
				} else {
					// isSameList = Arrays.equals(booleanlistBus, booleanlistBusCopy);
					for (int i = 0; i < p1; i++) {
						for (int j = 0; j < p2; j++) {
							for (int k = 0; k < p3; k++) {
								if (booleanlistVanCopy[i][j][k][0] != booleanlistVan[i][j][k][0]) {
									isSameList = false;
									break;
								}
								if (booleanlistVanCopy[i][j][k][1] != booleanlistVan[i][j][k][1]) {
									isSameList = false;
									break;
								}
							}
						}
					}

					if (otherfield.getText().toString().toLowerCase().equals((fo.getdamagedItemsOtherField().toLowerCase())))
						isSameText = true;
				}

				if (isSameList && isSameText) {
					finish();
					return;
				} else {
					AlertDialog.Builder alertbox = new AlertDialog.Builder(ExpList3_Van.this);
					alertbox.setTitle(R.string.saform);
					alertbox.setCancelable(false);
					alertbox.setMessage("Do you want to save changes?");
					alertbox.setPositiveButton("Yes",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface arg0, int arg1) {
									okCommon();
									removeDialog(arg1);
									finish();
								}
							});
					alertbox.setNegativeButton("No",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface arg0, int arg1) {
									backCommon();
									removeDialog(arg1);
									finish();
								}
							});
					alertbox.show();
					return;
				}
				
				/*boolean[][][][] a = new boolean[p1][p2][p3][p4];
				if (!fo.getisPreSelected()) {
					// Damaged Items
					fo.setisVehicleShow(true);
					fo.setdamagedItemsOtherField("");
					fo.setpredamagedItemsOtherField("");
					fo.setBooleanlistVan(a);
					fo.setBooleanprelistVan(a);
				} else {
					// Pre Damaged Items
					fo.setBooleanprelistVan(a);
					fo.setpredamagedItemsOtherField(otherfield.getText()
							.toString().trim());
				}*/
			}
			finish();
		} catch (Exception e) {
			LOG.error("editEnable:10334");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}

	public void on_click_reset_button(View v) {
		try {
			AlertDialog.Builder alertbox = new AlertDialog.Builder(ExpList3_Van.this);
			alertbox.setTitle(R.string.saform);
			alertbox.setCancelable(false);
			alertbox.setMessage("'Damaged Items' and 'PAD Items' will be reset. Are you sure?");
			alertbox.setPositiveButton("Yes",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface arg0, int arg1) {
							fo.setisVehicleShow(true);
							fo.setdamagedItemsOtherField("");
							fo.setpredamagedItemsOtherField("");
							
							fo.setBooleanlistBus(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistCar(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistLorry(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistVan(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistThreeWheel(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistMotorcycle(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistTractor4WD(new boolean[p1][p2][p3][p4]);
							fo.setBooleanlistHandTractor(new boolean[p1][p2][p3][p4]);
							
							fo.setBooleanprelistBus(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistCar(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistLorry(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistVan(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistThreeWheel(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistMotorcycle(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistTractor4WD(new boolean[p1][p2][p3][p4]);
							fo.setBooleanprelistHandTractor(new boolean[p1][p2][p3][p4]);

							Application.setFormObjectInstance(fo);
							removeDialog(arg1);
							finish();
						}
					});
			alertbox.setNegativeButton("No",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface arg0, int arg1) {
							removeDialog(arg1);
						}
					});
			alertbox.show();
		} catch (Exception e) {
			LOG.error("on_click_reset_button:10772");
			if (e != null) {
				LOG.error("Message: " + e.getMessage());
				LOG.error("StackTrace: " + e.getStackTrace());
			}
		}
	}	
}
